<?php

namespace app\api\logic;
use think\exception\HttpException;
use app\data\util\HttpUtil;
class FeiShuTalkLogic extends BasicLogic
{


    /**
     * @desc    发送飞书
     * @date    2024/09/11
     * @author  luckyXiong
     */
    public function send($mess)
    {
        try {
            // 准备要发送的数据
            $data = [
                'msg_type' => 'text',
                'content' => [
                    'text' => $this->getSetting() . "--系统报错:" . $mess,
                ],
            ];

            // 发送 POST 请求
            $response = HttpUtil::postDataCurl('https://open.feishu.cn/open-apis/bot/v2/hook/8e85738a-d796-46bf-b8c2-586b8af8a969', $data);
            // 检查响应状态
            if ($response['StatusCode']!== 200) {
                throw new HttpException($response['StatusCode'], '飞书消息投递失败');
            }

        } catch (\Exception $e) {
            return  $this->jsonMessage(201,false,'消息投递异常：' . $e->getMessage(),null);
        }
    }

    protected function getSetting(): string
    {
        return '生产环境';
    }








}